package com.baizhi.controller;

import com.baizhi.entity.Menu;
import com.baizhi.service.MenuService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("menu")
public class MenuController {
    @Autowired
    private MenuService menuService;
    @RequestMapping("selectAll")
    @ResponseBody
    public List<Menu> selectAll(){
        Subject subject = SecurityUtils.getSubject();
        boolean permitted = subject.isPermitted("select:menu");
        boolean admin = subject.hasRole("admin");
        boolean admin1 = subject.hasRole("superadmin");
        System.out.println(permitted);
        System.out.println(admin);
        System.out.println(admin1);
        return menuService.selectAll();


    }
}
